home *** CD-ROM | disk | FTP | other *** search
- /*
- * NORMFILE.C Exhibit normalization of files.
- *
- * The purpose of NORMFILE is to show just exactly what is meant
- * by the normalization of a file name.
- *
- * This program displays a prompt on the screen, asking for a
- * filename to normalize. If the user presses just ENTER, he is
- * returned to DOS. If the user types a string, it is normalized
- * into a filename, and then the user is prompted for another
- * filename.
- *
- * The command line format is as follows:
- *
- * normfile
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987-1989
- *
- */
-
-
- #include <stdio.h>
-
- #include <bfiles.h>
-
- #define NUL '\0'
-
- static char *descrip[] =
- {
- "NORMFILE normalizes file names. Normalization means:", "",
- " 1) Detecting all illegal characters, including extra periods ('.'),",
- " slashes ('/'), backslashes ('\\'), etc.;",
- " 2) Converting all letters to lower case;",
- " 3) Converting all slashes to backslashes;",
- " 4) Removing the trailing colon (':') from a possible device name;",
- " 5) Adding the current disk drive name (if no disk drive is named);",
- " 6) Adding the full path from the root directory if it is absent;",
- " 7) Resolving \".\" and \"..\";",
- " 8) Truncating each portion of the path name to eight characters",
- " + dot + three characters; and",
- " 9) Removing the dot from each portion of the path name where it",
- " is redundant.", "",
- "This does not include:","",
- " 1) Checking the existence of any portion of the path, or",
- " 2) Checking for the presence of a possible device (if a trailing",
- " colon is found).",
- "",
- NIL
- };
-
- void main (void)
- {
- char filename [80];
- char normname [80];
- char *pdescrip;
- int i = 0;
- int lastpart;
- int errcode;
-
- /* Print out description */
- for (i = 0, pdescrip = descrip[0];
- pdescrip != NIL;
- i++, pdescrip = descrip [i])
- puts (pdescrip);
-
- printf ("press ENTER for some examples: ");
- gets (filename);
-
- /* Show some examples of file normalization. */
- errcode = flnorm ("a:\\z.", normname, &lastpart);
- printf (" original =<%s>\n", "a:\\z.");
- printf (" normalization =<%s>\n", normname);
- printf (" filename =<%s>\n", &(normname [lastpart]));
- printf (" errcode = %d\n\n", errcode);
-
- errcode = flnorm ("..\\zap\\v.1234", normname, &lastpart);
- printf (" original =<%s>\n", "..\\zap\\v.1234");
- printf (" normalization =<%s>\n", normname);
- printf (" filename =<%s>\n", &(normname [lastpart]));
- printf (" errcode = %d\n\n", errcode);
-
- printf ("\nfile to normalize -- ENTER to quit?\n\n");
-
- do
- {
- /* Get a filename, or ENTER to terminate. */
- printf ("original = ");
- gets (filename);
-
- /* If we were not asked to terminate, go do the */
- /* normalization. */
- if (filename [0] != NUL)
- {
- errcode = flnorm (filename, normname, &lastpart);
-
- /* Show what FLNORM returned to the user. */
- printf (" normalization =<%s>\n", normname);
- printf (" filename =<%s>\n", &(normname [lastpart]));
- printf (" errcode = %d\n\n", errcode);
- }
- } while (filename [0] != NUL);
- }